Public Class frmSettings

    Private Sub frmSettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        With My.Settings
            Me.txtUserManagementStaleLogonDays.Text = .UserManagementStaleLogonDays.ToString
            Me.txtUserManagementStaleModifiedDays.Text = .UserManagementStaleModifiedDays.ToString

            Me.txtComputerManagementStaleLogonDays.Text = .ComputerManagementStaleLogonDays.ToString
            Me.txtComputerManagementStaleModifiedDays.Text = .ComputerManagementStaleModifiedDays.ToString
        End With

    End Sub

    Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click

        ApplySettings()

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

        Me.Close()

    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        ApplySettings()
        Me.Close()

    End Sub

    Private Sub ApplySettings()

        With My.Settings
            .LDAPHostName = Me.txtLDAPHost.Text
            .LDAPOUDN = Me.txtLDAPOUDN.Text

            'user management
            .UserManagementAttributeCleanupSetPath = Me.txtUserManagementAttributeCleanupSetFilePath.Text
            .UserManagementTargetGroupCN = Me.txtUserManagementTargetGroup.Text
            .UserManagementPendingDisableGroupCN = Me.txtUserManagementPendingDisableGroup.Text

            .UserManagementStaleLogonDays = Me.txtUserManagementStaleLogonDays.Text
            .UserManagementStaleModifiedDays = Me.txtUserManagementStaleModifiedDays.Text

            'computer management
            .ComputerManagementAttributeCleanupSetPath = Me.txtComputerManagementAttributeCleanupSetFilePath.Text
            .ComputerManagementTargetGroupCN = Me.txtComputerManagementTargetGroupCN.Text
            .ComputerManagementPendingDisableGroupCN = Me.txtComputerManagementPendingDisableGroup.Text

            .ComputerManagementNamePrefix = Me.txtComputerManagementPrefix.Text

            .ComputerManagementStaleLogonDays = Me.txtComputerManagementStaleLogonDays.Text
            .ComputerManagementStaleModifiedDays = Me.txtComputerManagementStaleModifiedDays.Text
        End With

        My.Settings.Save()

    End Sub

End Class